#!/bin/bash
# 判断文件夹是否存在
if [ ! -d "/opt/source/gitlab-12-3-stable-zh" ]; then
 mkdir -p /opt/source/gitlab-12-3-stable-zh
fi
cd /opt/source
# 下载汉化源码
if [ -f /opt/source/gitlab-12-3-stable-zh.tar.gz ]; then
    tar -xvf gitlab-12-3-stable-zh.tar.gz -C gitlab-12-3-stable-zh  --strip-components 1
else
    wget https://gitlab.com/xhang/gitlab/repository/12-3-stable-zh/archive.tar.bz2 -O gitlab-12-3-stable-zh.tar.gz
    tar -xvf gitlab-12-3-stable-zh.tar.gz -C gitlab-12-3-stable-zh  --strip-components 1
fi
if [ ! -d "/home/gitlab/back" ]; then
     mkdir -p /home/gitlab/back
fi
# 备份源数据
cp -r /opt/gitlab/embedded/service/gitlab-rails/* /home/gitlab/back
# 强制覆盖
cp -rf gitlab-12-3-stable-zh/* /opt/gitlab/embedded/service/gitlab-rails/
sudo add-apt-repository  "deb [arch=amd64] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
#重新配置
gitlab-ctl reconfigure
#重启gitlab
gitlab-ctl restart